home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / demos / Using Image Encoders and Decoders / Creating and Saving a Multiple-Frame Image / Enumerate frames / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2002-02-15  |  1.5 KB  |  63 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  7.   Dialogs, GDIPAPI, GDIPOBJ, GDIPUTIL, StdCtrls, ComObj;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Memo1: TMemo;
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.     { Private declarations }
  15.   public
  16.     { Public declarations }
  17.   end;
  18.  
  19. var
  20.   Form1: TForm1;
  21.  
  22. implementation
  23.  
  24. {$R *.dfm}
  25.  
  26. procedure TForm1.FormCreate(Sender: TObject);
  27. var
  28.   image: TGPImage;
  29.   count, frameCount: UINT;
  30.   DimensionIDs: PGUID;
  31.   strGuid: string;
  32.   var i: integer;
  33. type
  34.   TGUIDDynArray = array of TGUID;
  35. begin
  36.   Image := TGPImage.Create('..\..\..\Media\MultiFrame.tif');
  37.  
  38.    // How many frame dimensions does the Image object have?
  39.    count := image.GetFrameDimensionsCount;
  40.    memo1.Lines.Add(format('The number of dimensions is %d.', [count]));
  41.    GetMem(DimensionIDs, count * SizeOf(TGUID));
  42.  
  43.    // Get the list of frame dimensions from the Image object.
  44.    image.GetFrameDimensionsList(DimensionIDs, count);
  45.  
  46.  
  47.    for i := 0 to count - 1 do
  48.    begin
  49.      strGuid := GUIDToString(TGUIDDynArray(DimensionIDs)[i]);
  50.      memo1.Lines.Add('The first (and only) dimension ID is ' + strGuid);
  51.    end;
  52.  
  53.    // Get the number of frames in the first dimension.
  54.    frameCount := image.GetFrameCount(TGUIDDynArray(DimensionIDs)[0]);
  55.    memo1.Lines.Add('The number of frames in that dimension is '+ inttostr(frameCount));
  56.  
  57.    freemem(DimensionIDs);
  58.    image.Free;
  59. end;
  60.  
  61.  
  62. end.
  63.